package com.ddn.service.hall.impl;


import com.ddn.mapper.hall.FeastMapper;
import com.ddn.model.hall.Feast;
import com.ddn.service.hall.FeastService;

import com.ddn.util.ResultData;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/*
  ❀❀❀---扎根---❀❀❀
    ❤ @libing ❤
  
*/
@Service
public class FeastServiceImpl implements FeastService {

    @Autowired
    private FeastMapper feastMapper;

    /**
     * service查找全部宴会厅,并开始分页
     * @param map
     * @return
     */
    @Override
    public ResultData findAllfeast(HashMap<String, Object> map) {

        String pageNo = (String) map.get("page");
        String pageSize = (String) map.get("limit");
        PageHelper.startPage(Integer.parseInt(pageNo),Integer.parseInt(pageSize));
        List<Feast> feastList= feastMapper.findAllFeast(map);
        PageInfo<Feast> info =new PageInfo<>(feastList);
        long l = info.getTotal();
        if (feastList != null) {
            return ResultData.ok(feastList,l);
        }
        return ResultData.fail();

    }

    /**
     * 删除会客厅信息
     * @param map
     * @return
     */
    @Override
    public ResultData deleteFeast(HashMap<String, Object> map) {
        int i =feastMapper.deleteFeast(map);
        if (i >0) {
            return ResultData.ok();
        }
        return ResultData.fail();
    }


    /**
     * 添加宴会厅信息
     * @param map
     * @return
     */
    @Override
    public ResultData addFeast(HashMap<String, Object> map) {
        int i =feastMapper.addFeast(map);
        if (i >0) {
            return ResultData.ok();
        }
        return ResultData.fail();
    }

    /**
     * 更新宴会厅数据
     * @param map
     * @return
     */
    @Override
    public ResultData updateFeast(HashMap<String, Object> map) {
        int i =feastMapper.updateFeast(map);
        if (i >0) {
            return ResultData.ok();
        }
        return ResultData.fail();
    }

    @Override
    public ResultData batchFeast(List<Integer> ids) {
        int i =feastMapper.batchFeast(ids);
        if (i >0) {
            return ResultData.ok();
        }
        return ResultData.fail();
    }
}
